﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/*
读取TXT文件信息，并封装成info对象
 */
public class ReaderDataManager : MonoBehaviour {

	public TextAsset weaponInfoText;

	public Sprite Gatlin;

	void Start () {
		InitWeaponInfo();
	}


// id,名称,中文名,类型id,类型名,等级,是否自动,飞行速度,持续时间,充能时间,攻击力,攻击范围,
// 图标资源,战斗贴图,爆炸效果,发射声音,结束声音,特殊能力1,特殊能力 2,特殊能力3,描述
	void InitWeaponInfo(){
		string[] lineArray = weaponInfoText.ToString().Split('\n');
		foreach (string line in lineArray)
		{
			string[] proArray = line.Split(',');
			WeaponInfo WeaponInfo = new WeaponInfo();
			if(proArray[0] != ""){WeaponInfo.ID = int.Parse(proArray[0]);}
			if(proArray[1] != ""){WeaponInfo.Name = proArray[1];}
			if(proArray[2] != ""){WeaponInfo.NameChina = proArray[2];}
			if(proArray[3] != ""){WeaponInfo.TypeId = int.Parse(proArray[3]);}
			if(proArray[4] != ""){WeaponInfo.TypeName = proArray[4];}
            if (proArray[5] != "") { WeaponInfo.Grade = proArray[5]; }
			if(proArray[6] != ""){WeaponInfo.IsAuto = int.Parse(proArray[6]);}
			if(proArray[7] != ""){WeaponInfo.BaseType = int.Parse(proArray[7]);}
			if(proArray[8] != ""){WeaponInfo.Speed = float.Parse(proArray[8]);}
			if(proArray[9] != ""){WeaponInfo.DurationTime = float.Parse(proArray[9]);}
			if(proArray[10] != ""){WeaponInfo.AttackRateTime = float.Parse(proArray[10]);}
			if(proArray[11] != ""){WeaponInfo.Damage = float.Parse(proArray[11]);}
			if(proArray[12] != ""){WeaponInfo.AttackDistance = float.Parse(proArray[12]);}
			if(proArray[13] != ""){WeaponInfo.Icon = proArray[13];}
			if(proArray[14] != ""){WeaponInfo.Prefab_body = proArray[14];}
			if(proArray[15] != ""){WeaponInfo.Prefab_explosion = proArray[15];}
			if(proArray[16] != ""){WeaponInfo.MusicStart = proArray[16];}
			if(proArray[17] != ""){WeaponInfo.MusicEnd = proArray[17];}
			if(proArray[18] != ""){WeaponInfo.SpecOne = int.Parse(proArray[18]);}
			if(proArray[19] != ""){WeaponInfo.SpecTwo = int.Parse(proArray[19]);}
			if(proArray[20] != ""){WeaponInfo.SpecThree = int.Parse(proArray[20]);}
			if(proArray[21] != ""){WeaponInfo.Desc = proArray[21];}
			DataLists.instance.weaponInfos.Add(WeaponInfo);
		}
		// print("weaponInfos.count---->" + DataLists.instance.weaponInfos.Count);

	}



	

	


	void Update () {
		
	}
}
